<?php
/**
 * @name IndexController
 * @author 6p2b7gaqkyoe4aw\administrator
 * @desc 默认控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
 */
error_reporting(E_ALL^E_NOTICE^E_WARNING);
class CategoryController extends Yaf_Controller_Abstract {

	public function goods_categoryAction(){
		$info=json_decode(file_get_contents("php://input"),true);
		$sellerid=$info['sellerid'] ? $info['sellerid'] : $_REQUEST['sellerid'];
	
		//$catid=$_REQUEST['catid'] ? $_REQUEST['catid'] : '';
		$model = new CategoryModel();
	
	
		if($sellerid){
			$where['sellerid = ?']=$sellerid;
		}else{
			$where='';
		}
	
		$list = $model->get_goods_category($where);
		
		if($list) $goodsmodel=new GoodsModel();
		print_r($list);
		foreach ($list as $key=>&$val){
		 
			$goodswhere['goods_categoryid = ?']=$val['catid'];
		    $val['goods']=$goodsmodel->getList2($goodswhere);
			//print_r($temp);
			unset($goodswhere);
			
		}
		//print_r($list);
	echo json_encode($list);
	}
	
	public function categoryListAction(){
		$info=json_decode(file_get_contents("php://input"),true);
		$catid=$info['catid'] ? $info['catid'] : $_REQUEST['catid'];
		
		//$catid=$_REQUEST['catid'] ? $_REQUEST['catid'] : '';
		$model = new CategoryModel();
		
		
		if($catid){
			$where['catid = ?']=$catid;
		}else{
			$where='';
		}
		
		$list = $model->getList($where);
		
		
		//print_r($list); 
		echo json_encode($list);
	}
	
}
